package service

import (
	"ksd-social-api/commons/base/service"
	"ksd-social-api/modules/special/model"
	"ksd-social-api/modules/special/model/context"
	"ksd-social-api/utils"
	"strconv"
)

type AdminSpecialBindDetailService struct {
	service.BaseService
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  修改状态
 */
func (service *AdminSpecialBindDetailService) UpdateFieldById(ctx context.SpecialUpdateContext) bool {
	return adminSpecialBindDetailMapper.UpdateFieldById(ctx.Id.Uint64(), ctx.Field, ctx.Value, ctx.SystemId)
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  修改状态
 */
func (service *AdminSpecialBindDetailService) SaveUpdateSpecialBindDetail(ctx context.SpecialBindDetailContext) *model.SpecialBindDetail {
	// 保存入库
	var specialBindDetail model.SpecialBindDetail
	utils.CopyProperties(&specialBindDetail, ctx)
	parseUint, _ := strconv.ParseUint(ctx.Id, 10, 64)
	specialBindDetail.Id = parseUint
	specialBindDetail.SpecialId = ctx.SpecialId.Uint64()
	specialBindDetail.TeacherId = ctx.TeacherId.Uint64()
	specialBindDetail.NoteId = ctx.NoteId.Uint64()
	specialBindDetail.BindId = ctx.BindId.Uint64()
	data := adminSpecialBindDetailMapper.SaveUpdateSpecialBindDetail(specialBindDetail)
	return data
}

/**
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 * @desc  根据id删除
 */
func (service *AdminSpecialBindDetailService) DelById(id uint64, systemId uint64) bool {
	return adminSpecialBindDetailMapper.DelById(id, systemId)
}

func (mapper *AdminSpecialBindDetailService) CountSpecialBindDetailNoteCount(ctx context.SpecialBindDetailContext) int64 {
	return adminSpecialBindDetailMapper.CountSpecialBindDetailNoteCount(ctx.NoteId.Uint64(), ctx.BindId.Uint64(), ctx.SpecialId.Uint64(), ctx.SystemId)
}

func (mapper *AdminSpecialBindDetailService) CountSpecialBindDetailTeacherCount(ctx context.SpecialBindDetailContext) int64 {
	return adminSpecialBindDetailMapper.CountSpecialBindDetailTeacherCount(ctx.TeacherId.Uint64(), ctx.BindId.Uint64(), ctx.SpecialId.Uint64(), ctx.SystemId)
}
